//
//  NetWorkCallBack.m
//  mendianjieke
//
//  Created by 响当当 on 9/6/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "NetWorkCallBack.h"

@implementation NetWorkCallBack

- (NSURLSessionDataTask *)GET:(NSString *)URLString
                   parameters:(id)parameters
                      success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                      failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
{
    
    void (^authFailBlock)(NSURLSessionDataTask *task, NSError *error) = ^(NSURLSessionDataTask *task, NSError *error)
    {
        if (error.code == 401)
        {
            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
                [self refreshAccessToken:^(AFHTTPRequestSerializer *responseObject) {
                    
                }];
            });
        }
    };
    
    
    
    NSURLSessionDataTask *stask = [super GET:URLString
                                  parameters:parameters
                                     success:success
                                     failure:authFailBlock];
    
    return stask;

}


-(void)refreshAccessToken:(void(^)(AFHTTPRequestSerializer *responseObject))refresh

{
    
}

@end
